home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / UDDIWEB.MSI / editcontact.aspx < prev    next >
Encoding:
Text File  |  2003-02-21  |  14.3 KB  |  453 lines

  1. <!-- ############################################################################ -->
  2. <!-- ## UDDI Services                                                          ## -->
  3. <!-- ## Copyright (c) Microsoft Corporation.  All rights reserved.             ## -->
  4. <!-- ############################################################################ -->
  5.  
  6. <%@ Page Language='C#' Inherits='UDDI.Web.UddiPage' %>
  7. <%@ Register TagPrefix='uddi' Namespace='UDDI.Web' Assembly='uddi.web' %>
  8. <%@ Register Tagprefix='uddi' Tagname='Header' Src='../controls/header.ascx' %>
  9. <%@ Register Tagprefix='uddi' Tagname='Footer' Src='../controls/footer.ascx' %>
  10. <%@ Register Tagprefix='uddi' Tagname='BreadCrumb' Src='../controls/breadcrumb.ascx' %>
  11. <%@ Register Tagprefix='uddi' Tagname='Descriptions' Src='../controls/descriptions.ascx' %>
  12. <%@ Register Tagprefix='uddi' Tagname='Email' Src='../controls/emails.ascx' %>
  13. <%@ Register Tagprefix='uddi' Tagname='Phone' Src='../controls/phones.ascx' %>
  14. <%@ Register Tagprefix='uddi' Tagname='Address' Src='../controls/address.ascx' %>
  15. <%@ Import Namespace='UDDI' %>
  16. <%@ Import Namespace='UDDI.API' %>
  17. <%@ Import Namespace='UDDI.API.Business' %>
  18. <%@ Import Namespace='System.Data' %>
  19.  
  20. <script language='C#' runat='server'>
  21.     protected BusinessEntity business = new BusinessEntity();
  22.     protected Contact contact = new Contact();
  23.  
  24.     protected bool frames = false;
  25.     protected string key;
  26.     protected string mode;
  27.     protected int contactIndex;
  28.         
  29.     protected void Page_Init( object sender, EventArgs e )
  30.     {
  31.         frames = ( "true" == Request[ "frames" ] );
  32.         key = Request[ "key" ];
  33.         mode = Request[ "mode" ];
  34.  
  35.         string requestIndex = Request[ "index" ];
  36.         
  37.         if( null == key )
  38.         {
  39. #if never
  40.             throw new UDDIException(
  41.                 ErrorType.E_fatalError,
  42.                 "Missing required parameter 'key'." );
  43. #endif
  44.             throw new UDDIException( ErrorType.E_fatalError, "UDDI_ERROR_MISSING_REQUIRED_KEY_PARAMETER" );
  45.         }
  46.  
  47.         if( null == requestIndex && "add" != mode )
  48.         {
  49. #if never
  50.             throw new UDDIException(
  51.                 ErrorType.E_fatalError,
  52.                 "Missing required parameter 'index'." );
  53. #endif
  54.             throw new UDDIException( ErrorType.E_fatalError, "UDDI_ERROR_MISSING_REQUIRED_INDEX_PARAMETER" );
  55.         }
  56.         
  57.         contactIndex = Convert.ToInt32( requestIndex );
  58.         
  59.         switch( mode )
  60.         {
  61.             case "add":
  62.                 business.BusinessKey = key;
  63.                 business.Get();
  64.                 
  65.                 contact.PersonName = Localization.GetString( "DEFAULT_CONTACT_NAME" );
  66.                 business.Contacts.Add( contact );
  67.                 business.Save();
  68.                 
  69.                 contactIndex = business.Contacts.Count - 1;
  70.                 
  71.                 if( frames )
  72.                 {
  73.                     //
  74.                     // Reload explorer and view panes.
  75.                     //
  76.                     Response.Write(
  77.                         ClientScripts.ReloadExplorerAndViewPanes( 
  78.                             "editcontact.aspx?key=" + business.BusinessKey + "&index=" + contactIndex + ( frames ? "&frames=true" : "" ),
  79.                             business.BusinessKey + ":" + contactIndex ) );
  80.                 
  81.                     Response.End();
  82.                 }
  83.                 else
  84.                 {
  85.                     Response.Redirect( "editcontact.aspx?key=" + business.BusinessKey + "&index=" + contactIndex );
  86.                     Response.End();
  87.                 }
  88.                 
  89.                 break;
  90.                 
  91.             case "delete":
  92.                 business.BusinessKey = key;
  93.                 business.Get();
  94.                 
  95.                 contact = business.Contacts[ contactIndex ];
  96.  
  97.                 if( null == Request[ "confirm" ] )
  98.                 {
  99.                     //
  100.                     // The user has not yet confirmed the delete operation, so display
  101.                     // a confirmation dialog.
  102.                     //
  103.                     string message = String.Format( Localization.GetString( "TEXT_DELETE_CONFIRMATION" ), contact.PersonName );
  104.                     
  105.                     Page.RegisterStartupScript(
  106.                         "Confirm",
  107.                         ClientScripts.Confirm(
  108.                             message,
  109.                             "editcontact.aspx?key=" + key + "&index=" + contactIndex + ( frames ? "&frames=true" : "" ) + "&mode=delete&confirm=true",
  110.                             "editcontact.aspx?key=" + key + "&index=" + contactIndex + ( frames ? "&frames=true" : "" ) ) );
  111.                                 
  112.                     break;
  113.                 }
  114.                 
  115.                 //
  116.                 // The user has confirmed the delete, so go ahead and delete
  117.                 // the entity.  Then reload the tree view.
  118.                 //
  119.                 
  120.                 business.Contacts.Remove( contact );
  121.                 business.Save();
  122.                         
  123.                 if( frames )
  124.                 {
  125.                 Response.Write( 
  126.                     ClientScripts.ReloadExplorerAndViewPanes( 
  127.                         "editbusiness.aspx?frames=true&key=" + business.BusinessKey + ( null != Request[ "tab" ] ? "&tab=" + Request[ "tab" ] : "" ),
  128.                         business.BusinessKey ) );
  129.                             
  130.                     Response.End();
  131.                 }
  132.                 else
  133.                 {
  134.                     Response.Redirect( "editbusiness.aspx?frames=false&key=" + business.BusinessKey + ( null != Request[ "tab" ] ? "&tab=" + Request[ "tab" ] : "" ) );
  135.                     Response.End();
  136.                 }
  137.             
  138.                 break;
  139.             
  140.             default:
  141.                 business.BusinessKey = key;
  142.                 business.Get();
  143.                 
  144.                 contact = business.Contacts[ contactIndex ];
  145.             
  146.                 break;
  147.         }
  148.     }
  149.     
  150.     protected void Page_Load( object sender, EventArgs e )
  151.     {
  152.         descriptions.Initialize( contact.Descriptions, business );
  153.         emails.Initialize( contact.Emails, business );
  154.         phones.Initialize( contact.Phones, business );
  155.         addresses.Initialize( contact.Addresses, business );
  156.         
  157.         
  158.     }
  159.     protected void Page_PreRender( object sender, EventArgs e )
  160.     {
  161.         breadcrumb.Initialize( BreadCrumbType.Edit, EntityType.Contact, key, contactIndex );
  162.     }
  163.  
  164.     public void Edit_OnClick( object sender, CommandEventArgs e )
  165.     {
  166.         contactDetail.SetEditMode();
  167.         
  168.         TextBox textBox = (TextBox)contactDetail.ActiveControl.FindControl( "editName" );
  169.         textBox.Text = contact.PersonName;
  170.         
  171.         TextBox textBoxUseType = (TextBox)contactDetail.ActiveControl.FindControl( "editUseType" );
  172.         textBoxUseType.Text = contact.UseType;
  173.         
  174.         RequiredFieldValidator requiredName = (RequiredFieldValidator)contactDetail.ActiveControl.FindControl( "requiredName" );
  175.         requiredName.ErrorMessage = Localization.GetString( "ERROR_FIELD_REQUIRED" );        
  176.     }
  177.     
  178.     public void Update_OnClick( object sender, EventArgs e )
  179.     {
  180.         //
  181.         // BUG: 728086
  182.         //      Netscape isn't firing the validate code correctly in all cases,
  183.         //        so, we must call validate our selves.  We do this in other places in the UI
  184.         //        already.
  185.         //
  186.         Page.Validate();
  187.         
  188.         Update_OnClick( sender, null );
  189.     }
  190.     
  191.     public void Update_OnClick( object sender, CommandEventArgs e )
  192.     {
  193.         if( Page.IsValid )
  194.         {
  195.             TextBox textBox = (TextBox)contactDetail.ActiveControl.FindControl( "editName" );
  196.             contact.PersonName = textBox.Text;
  197.             
  198.             TextBox textBoxUseType = (TextBox)contactDetail.ActiveControl.FindControl( "editUseType" );
  199.             contact.UseType = textBoxUseType.Text;
  200.             
  201.             business.Save();
  202.  
  203.             contactDetail.CancelEditMode();
  204.             
  205.             Label label = (Label)contactDetail.ActiveControl.FindControl( "displayName" );
  206.             label.Text = contact.PersonName;
  207.             
  208.             Label labelUseType = (Label)contactDetail.ActiveControl.FindControl( "displayUseType" );
  209.             labelUseType.Text = Utility.StringEmpty( contact.UseType ) ? Localization.GetString( "HEADING_NONE" ) : contact.UseType;
  210.             
  211.             Page.RegisterStartupScript(
  212.                 "Reload",
  213.                 ClientScripts.ReloadExplorerPane(
  214.                     business.BusinessKey + ":" + contactIndex ) );                
  215.         }        
  216.     }
  217.     
  218.     public void Cancel_OnClick( object sender, CommandEventArgs e )
  219.     {
  220.         contactDetail.CancelEditMode();
  221.     }
  222.     
  223. </script>
  224. <uddi:StyleSheetControl
  225.     Runat='server'
  226.     Default='../stylesheets/uddi.css' 
  227.     Downlevel='../stylesheets/uddidl.css' 
  228.     />
  229. <uddi:PageStyleControl 
  230.     Runat='server'
  231.     OnClientContextMenu='Document_OnContextMenu()'
  232.     Title="TITLE"
  233.     AltTitle="TITLE_ALT"
  234.     />
  235. <uddi:ClientScriptRegister
  236.     Runat='server'
  237.     Source='../client.js'
  238.     Language='javascript'
  239.     />
  240. <uddi:SecurityControl 
  241.     PublisherRequired='true' 
  242.     Runat='server' 
  243.     />
  244. <form runat='server'>
  245.  
  246. <table width='100%' border='0' height='100%' cellpadding='0' cellspacing='0'>
  247.         <asp:PlaceHolder
  248.             Id='HeaderBag'
  249.             Runat='server'
  250.             >
  251.             <tr height='95'>
  252.                 <td>
  253.                     <!-- Header Control Here -->
  254.                     <uddi:Header
  255.                         Runat='server' 
  256.                         />
  257.                 </td>
  258.             </tr>
  259.         </asp:PlaceHolder>
  260.         <tr height='100%' valign='top'>
  261.             <td>            
  262.                 <uddi:BreadCrumb 
  263.                     Id='breadcrumb' 
  264.                     Runat='server' 
  265.                     />
  266.                 <table cellpadding='10' cellspacing='0' border='0' width='100%'>
  267.                     <tr>
  268.                         <td>
  269.                             <uddi:UddiLabel Text='[[HELP_BLOCK_PUBLISH_CONTACT]]' CssClass='helpBlock' Runat='server' /><br>
  270.                             <br>
  271.                             <uddi:TabControl ID='tabs' Runat='server'>
  272.                                 <uddi:TabPage Name='TAB_DETAILS' Runat='server'>                            
  273.                                     <uddi:ContextualHelpControl 
  274.                                         Runat='Server'
  275.                                         Text='[[HELP_BLOCK_PUBLISH_CONTACT_DETAILS]]'
  276.                                         HelpFile='publish.context.publishcontactdetails'
  277.                                         CssClass='tabHelpBlock'
  278.                                         BorderWidth='0'
  279.                                         />
  280.                                     
  281.                                     <br>
  282.                                     <uddi:EditControl 
  283.                                             id='contactDetail' 
  284.                                             OnEditCommand='Edit_OnClick' 
  285.                                             OnUpdateCommand='Update_OnClick' 
  286.                                             OnCancelCommand='Cancel_OnClick' 
  287.                                             Runat='server'>
  288.                                         <EditItemTemplate>
  289.                                             <table width='100%' cellpadding='4' cellspacing='0' border='0'>
  290.                                                 <colgroup>
  291.                                                     <col width='0*'>
  292.                                                     <col width='154'>
  293.                                                 </colgroup>                                            
  294.                                                 <tr>
  295.                                                     <td class='tableHeader'>
  296.                                                         <uddi:StringResource Name='HEADING_CONTACT' Runat='Server' /></td>
  297.                                                     <td class='tableHeader' width='150'>
  298.                                                         <uddi:StringResource Name='HEADING_ACTIONS' Runat='Server' /></td>
  299.                                                 </tr>
  300.                                                 <tr valign='top'>                                                
  301.                                                     <td class='tableEditItem'>
  302.                                                         <uddi:LocalizedLabel 
  303.                                                                 Name='TAG_CONTACT_NAME' 
  304.                                                                 CssClass='lightHeader' 
  305.                                                                 Runat='Server' /><br>
  306.                                                         <uddi:UddiTextBox 
  307.                                                                 ID='editName' 
  308.                                                                 Width='200px'
  309.                                                                 Selected='true'
  310.                                                                 OnEnterKeyPressed='Update_OnClick'
  311.                                                                 MaxLength='255' 
  312.                                                                 Runat='server' /><br>
  313.                                                         <asp:RequiredFieldValidator
  314.                                                                 id='requiredName'
  315.                                                                 ControlToValidate='editName'
  316.                                                                 Display='Dynamic'
  317.                                                                 Runat='server'/>                                        
  318.                                                         <br>
  319.                                                         <uddi:UddiLabel 
  320.                                                                 Text='[[TAG_USE_TYPE]]' 
  321.                                                                 CssClass='lightHeader' 
  322.                                                                 Runat='Server' /><br>
  323.                                                         <uddi:UddiTextBox 
  324.                                                                 ID='editUseType' 
  325.                                                                 Width='200px'
  326.                                                                 OnEnterKeyPressed='Update_OnClick'
  327.                                                                 MaxLength='255' 
  328.                                                                 Runat='server' /></td>
  329.  
  330.                                                     <td class='tableEditItem'>
  331.                                                         <uddi:UddiButton 
  332.                                                                 Text='<%# Localization.GetString( "BUTTON_UPDATE" )%>' 
  333.                                                                 CommandName='update' 
  334.                                                                 Width='70px' 
  335.                                                                 CssClass='button' 
  336.                                                                 Runat='server' />
  337.                                                                  
  338.                                                         <uddi:UddiButton 
  339.                                                                 Text='<%# Localization.GetString( "BUTTON_CANCEL" )%>' 
  340.                                                                 CommandName='cancel' 
  341.                                                                 CausesValidation='false' 
  342.                                                                 Width='70px' 
  343.                                                                 CssClass='button' 
  344.                                                                 Runat='server' /></td>
  345.                                                 </tr>
  346.                                             </table>                                        
  347.                                         </EditItemTemplate>
  348.  
  349.                                         <ItemTemplate>
  350.                                             <table width='100%' cellpadding='4' cellspacing='0' border='0'>
  351.                                                 <colgroup>
  352.                                                     <col width='0*'>
  353.                                                     <col width='154'>
  354.                                                 </colgroup>                                            
  355.                                                 <tr>
  356.                                                     <td class='tableHeader'>
  357.                                                         <uddi:StringResource 
  358.                                                                 Name='HEADING_CONTACT' 
  359.                                                                 Runat='Server' /></td>
  360.                                                     <td class='tableHeader' width='150'>
  361.                                                         <uddi:StringResource 
  362.                                                                 Name='HEADING_ACTIONS' 
  363.                                                                 Runat='Server' /></td>
  364.                                                 </tr>
  365.                                                 <tr valign='top'>
  366.                                                     <td class='tableItem'>
  367.                                                         <uddi:UddiLabel 
  368.                                                                 Text='<%# contact.PersonName %>' 
  369.                                                                 ID='displayName' 
  370.                                                                 Runat='server' /><br>
  371.                                                         <uddi:UddiLabel 
  372.                                                                 Text='[[TAG_USE_TYPE]]' 
  373.                                                                 CssClass='lightHeader' 
  374.                                                                 Runat='Server' />
  375.                                                         <uddi:UddiLabel
  376.                                                                 Text='<%# Utility.Iff( Utility.StringEmpty( contact.UseType ), Localization.GetString( "HEADING_NONE" ), contact.UseType ) %>' 
  377.                                                                 ID='displayUseType'
  378.                                                                 Runat='server' /></td>
  379.                                                     <td class='tableItem'>
  380.                                                         <uddi:UddiButton 
  381.                                                                 Text='<%# Localization.GetString( "BUTTON_EDIT" )%>' 
  382.                                                                 CommandName='edit' 
  383.                                                                 Width='70px' 
  384.                                                                 CssClass='button' 
  385.                                                                 Runat='server' /></td>
  386.                                                 </tr>
  387.                                             </table>                                        
  388.                                         </ItemTemplate>                                                                    
  389.                                     </uddi:EditControl><br>
  390.                                     <br>
  391.                                     <uddi:Descriptions ID='descriptions' Runat='server' />
  392.                                 </uddi:TabPage>
  393.                                 
  394.                                 <uddi:TabPage Name='TAB_EMAILS' Runat='server'>                            
  395.                                     <uddi:ContextualHelpControl 
  396.                                         Runat='Server'
  397.                                         Text='[[HELP_BLOCK_PUBLISH_CONTACT_EMAILS]]'
  398.                                         HelpFile='publish.context.publishcontactemail'
  399.                                         CssClass='tabHelpBlock'
  400.                                         BorderWidth='0'
  401.                                         />
  402.                                 
  403.                                     <br>
  404.                                     <uddi:Email ID='emails' Runat='Server' />
  405.                                 </uddi:TabPage>
  406.  
  407.                                 <uddi:TabPage Name='TAB_PHONES' Runat='server'>                            
  408.                                     <uddi:ContextualHelpControl 
  409.                                         Runat='Server'
  410.                                         Text='[[HELP_BLOCK_PUBLISH_CONTACT_PHONES]]'
  411.                                         HelpFile='publish.context.publishcontactphone'
  412.                                         CssClass='tabHelpBlock'
  413.                                         BorderWidth='0'
  414.                                         />
  415.                                     
  416.                                     <br>    
  417.                                     <uddi:Phone ID='phones' Runat='Server' />
  418.                                 </uddi:TabPage>
  419.  
  420.                                 <uddi:TabPage Name='TAB_ADDRESSES' Runat='server'>                            
  421.                                     <uddi:ContextualHelpControl 
  422.                                         Runat='Server'
  423.                                         Text='[[HELP_BLOCK_PUBLISH_CONTACT_ADDRESSES]]'
  424.                                         HelpFile='publish.context.publishcontactaddress'
  425.                                         CssClass='tabHelpBlock'
  426.                                         BorderWidth='0'
  427.                                         />
  428.                                     
  429.                                     <br>
  430.                                     <uddi:Address ID='addresses' Runat='server' />
  431.                                 </uddi:TabPage>
  432.                             </uddi:TabControl>
  433.                         </td>
  434.                     </tr>
  435.                 </table>
  436.             </td>
  437.         </tr>
  438.         <asp:PlaceHolder 
  439.             Id='FooterBag'
  440.             Runat='server'
  441.             >
  442.             <tr height='95'>
  443.                 <td>
  444.                     <!-- Footer Control Here -->
  445.                     <uddi:Footer
  446.                         Runat='server' 
  447.                         />
  448.                 </td>
  449.             </tr>
  450.         </asp:PlaceHolder>
  451.     </table> 
  452. </form>
  453.